﻿$(document).ready(function () {

    if ($("#result").html() == "添加成功" || $("#result").html() == "修改成功") {
        //$("#submitBtn").attr('disabled', 'disabled');//设置disabled属性为true，按钮不可用 
        //$("#submitBtn").css('background', '#ccc');
        //关闭当前对话框并刷新父页面
        $(window.top.document).find("#searchBtn").click();
        window.top.art.dialog.get('operationmanageunitcreate').close();
    }

    $("#selectParentUnit").click(function () {
        artDialogForm("/Unit/PickParentUnit", "选择所属单位", "operationmanageunitcreatepickparentunit", 400, 300);
    });

    var validator = $("#unitcreateform").validate({
        errorPlacement: function (error, element) {
            error.appendTo(element.parent());
        },
        rules: {
            UNITNAME:
            {
                required: true,
                maxlength: 50
            },
            PARTENTUNITNAME:
            {
                required: true,
                maxlength: 50
            },
            Address:
            {
                maxlength: 50
            },
            BusinessLicense:
            {
                maxlength: 50
            },
            IDnumbers:
            {
                maxlength: 50
            },
            BankName:
            {
                maxlength: 100
            },
            BankId:
            {
                maxlength: 50
            },
            ContactPeo:
            {
                maxlength: 50
            },
            ContactCelTel:
            {
                maxlength: 50
            },
            ZIP:
            {
                maxlength: 50
            },
            ContactTel:
            {
                maxlength: 50
            },
            Email:
            {
                email: true
            },
            Fax:
            {
                maxlength: 50
            },
            Fmemo:
            {
                maxlength: 255
            },
            cardDate:
            {
                maxlength: 255
            }
        }
        //onfocusout: function(element) { $(element).valid(); }
    });

    $("#submitBtn").click(function () {
        if (validator.form()) {
            $("#unitcreateform").submit();
        }
    });
});